<template>
  <div class="footer_guide border-1px">
    <div href="javascript:;" class="guide_item "  @click="goto('/main')" :class="{on: '/main'===$route.path}">
      <span class="item_icon">
        <i class="iconfont icon-waimai"></i>
      </span>
      <span>外卖</span>
    </div>
 
    <a href="javascript:;" class="guide_item " @click="goto('/search')" :class="{on: '/search'===$route.path}">    <!--判断当前路由是不是相等，相等就加on  -->
      <span class="item_icon">
        <i class="iconfont icon-search"></i>
      </span>
      <span>搜索</span>
    </a>
    <a href="javascript:;" class="guide_item"  @click="goto('/order')" :class="{on: ispath('/order')}">   <!--判断当前路由是不是相等，相等就加on  -->
      <span class="item_icon">
        <i class="iconfont icon-dingdan"></i>
      </span>
      <span>订单</span>
    </a>
    <a href="javascript:;" class="guide_item"  @click="goto('/profile')" :class="{on: ispath('/profile')}">
      <span class="item_icon">
        <i class="iconfont icon-geren"></i>
      </span>
      <span>我的</span>
    </a>
  </div>
</template>

<script>
export default {
  methods:{
    // 点击切换路由函数
    goto(path){
      return  this.$router.replace(path) //replace是替换掉当前记录
    },
    ispath(path){
      // 判断当前路由是不是相等，相等就加on
      return this.$route.path===path
    }

  }

}
</script>

<style lang='stylus' ref='stylesheet/stylus'>
@import "../../common/stylus/mixins.styl"
    .footer_guide  //footer
      top-border-1px(#e4e4e4)
      position fixed
      z-index 100
      left 0
      right 0
      bottom 0
      background-color #fff
      width 100%
      height 50px
      display flex
    .guide_item
      text-decoration: none
      display flex
      flex 1
      text-align center
      flex-direction column
      align-items center
      margin 5px
      color #999999
      &.on
        color #02a774
      span
        font-size 12px
        margin-top 2px
        margin-bottom 2px
        .iconfont
          font-size 22px
</style>